<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<title>克隆日期框 - jQuery EasyUI 演示</title>
	<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="../../themes/default/easyui.css">
	<link rel="stylesheet" type="text/css" href="../../themes/icon.css">
	<link rel="stylesheet" type="text/css" href="../demo.css">
	<script type="text/javascript" src="../../jquery.min.js"></script>
	<script type="text/javascript" src="../../jquery.easyui.min.js"></script>
	<script type="text/javascript" src="../../locale/easyui-lang-zh_CN.js"></script>
	<style>
		#cc label {margin-top:10px;}
	</style>
</head>
<body>
	<h2 title="Clone DateBox">克隆日期框</h2>
	<p title="Click the 'Clone' button to clone datebox components from the exiting datebox.">　　点击【克隆】按钮即可从已有的日期框复制出一个完全同样的日期框组件。再点【全清】钮即可销毁已克隆出的全部日期框。</p>
	<div style="margin:10px 0;">
		<a href="javascript:void(0)" class="easyui-linkbutton" onclick="cloneDatebox()">&nbsp;克隆&nbsp;</a>
		<a id="btnCC" href="javascript:void(0)" class="easyui-linkbutton" disabled="true" onclick="clearCloneDbxs()">&nbsp;全清&nbsp;</a>
	</div>
	<div class="easyui-panel" style="width:100%;max-width:250px;padding:10px 20px 5px;">
		<div style="margin-bottom:5px">
			<input id="dt" class="easyui-datebox" label="选日期：" labelPosition="left" labelWidth="100" labelAlign="right" style="width:100%;">
		</div>
		<div id="cc" style="margin-bottom:5px"></div>
	</div>
	<script type="text/javascript">
		var cQty=0;
		function cloneDatebox(){
			var dt=$('<input>').appendTo('#cc'); cQty++; dt.datebox('cloneFrom', '#dt');
			dt.datebox({label:'克隆'+cQty+$('#dt').datebox('options').label}); $('#btnCC').linkbutton('enable');
		}
		function clearCloneDbxs(){
			if(cQty>0){
				$.messager.confirm('确认操作', '真的要把已克隆出的全部日期框销毁吗？<br/>　　共 '+cQty+' 个。', function(r){
					if(r){cQty=0; $("#cc").empty(); $('#btnCC').linkbutton('disable');}
				});
			}
		}
	</script>
</body>
</html>